home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyo (Python 2.1)
-
- import os
- import pygame
- import copy
- from pygame.locals import *
- from random import randint
-
- def load_image_init():
- global image_dict
- image_dict = { }
-
-
- def load_image(name, colorkey = None, cache = 1):
- if not image_dict.has_key(name) or not cache:
-
- try:
- if colorkey is not None:
- image = pygame.image.load(name)
- image.convert()
- if colorkey is not None and colorkey != 0:
- if colorkey is -1:
- colorkey = image.get_at((0, 0))
-
- colorkey_used = image.set_colorkey(colorkey, RLEACCEL)
-
- else:
- image = pygame.image.load(name)
- image = image.convert_alpha()
- except pygame.error:
- message = None
- return (None, None)
-
- image_dict[name] = image
- return (image, image.get_rect())
- else:
- return (image_dict[name], image_dict[name].get_rect())
-
-
- def load_dict(filename, dict, compressed = 0):
- if not os.path.exists(filename):
- return None
-
- if compressed == 0:
- file = open(filename, 'rb')
- else:
- file = gzip.open(filename, 'rb')
- lines = file.readlines()
- for line in lines:
- line = line.rstrip()
- (key, value) = line.split('=', 1)
-
- try:
- int(value)
- except ValueError:
- 0
- 0
- lines
- except:
- 0
-
- value = int(value)
- dict[key] = copy.deepcopy(value)
-
- file.close()
-
-
- def load_file(filename):
- if not os.path.exists(filename):
- return None
-
- file = open(filename, 'rb')
- data = file.read()
- return data
-
-
- def save_file(filename, data):
- file = open(filename, 'wb')
- file.write(data)
-
-
- def save_dict(filename, dict, compressed = 0):
- if compressed == 0:
- file = open(filename, 'wb')
- else:
- file = gzip.open(filename, 'wb')
- for item in dict.items():
- file.write('%s=%s\n' % (str(item[0]), str(item[1])))
-
- file.close()
-
-
- def draw_text_init(screenRect, screen, gameScreen):
- global font_dict
- font_dict = { }
-
-
- def draw_text(text, size, color, pos, surface, align_flag = 0, draw_flag = 0, draw_flag_data = 0, width = -1, effect = 0, effectPer = 1.0):
- offset = [
- 0,
- 0]
- if not (pygame.font):
- return offset
-
- if text == '':
- return offset
-
- if font_dict.has_key(size) == 0:
- font_dict[size] = pygame.font.Font('data/tahoma.ttf', size)
-
- if text.find('\n', 0) != -1:
- lines = text.split('\n')
- else:
- lines = text.split('\\n')
- count = 0
- if effect != 0:
- if effect == 1:
- if effectPer > 0.5:
- effectPer = 0.5 - effectPer - 0.5
-
- scale = 1.0 + 0.17 * effectPer
-
-
- for line in lines:
- count += 1
-
- return (offset, count)
-
-